home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / DTS Sample Code / System 7.0 Samples / Kibitz / Sound.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-21  |  1.9 KB  |  107 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** Program:          Kibitz
  5. ** File:             sound.c
  6. ** Originally from:  SoundCdev by Jeremy Bornstein
  7. ** Modified by:      Eric Soldan
  8. **
  9. ** Copyright © 1990-1991 Apple Computer, Inc.
  10. ** All rights reserved.
  11. */
  12.  
  13.  
  14.  
  15. /*****************************************************************************/
  16.  
  17.  
  18.  
  19. #include "Kibitz.h"                /* Get the Kibitz includes/typedefs, etc.    */
  20. #include "KibitzCommon.h"        /* Get the stuff in common with rez.        */
  21. #include "Kibitz.protos"        /* Get the prototypes for Kibitz.            */
  22.  
  23. #ifndef __ERRORS__
  24. #include <Errors.h>
  25. #endif
  26.  
  27. #ifndef __FILES__
  28. #include <Files.h>
  29. #endif
  30.  
  31. #ifndef __SOUND__
  32. #include <Sound.h>
  33. #endif
  34.  
  35. #ifndef __SOUNDINPUT__
  36. #include <SoundInput.h>
  37. #endif
  38.  
  39. #ifndef __UTILITIES__
  40. #include <Utilities.h>
  41. #endif
  42.  
  43.  
  44.  
  45. /*****************************************************************************/
  46. /*****************************************************************************/
  47.  
  48.  
  49.  
  50. #pragma segment Main
  51. OSErr    RecordSound(FileRecHndl frHndl)
  52. {
  53.     Handle    newSnd, oldSnd;
  54.     OSErr    err;
  55.     Point    corner = {50, 50};
  56.  
  57.     if (!(newSnd = NewHandle(31 * 1024)))
  58.         return(memFullErr);
  59.  
  60.     err = SndRecord(nil, corner, siBetterQuality, &newSnd);
  61.  
  62.     if (!err) {
  63.         if (oldSnd = (*frHndl)->doc.sound) DisposHandle(oldSnd);
  64.         (*frHndl)->doc.sound = newSnd;
  65.     }
  66.     else DisposHandle(newSnd);
  67.  
  68.     return(err);
  69. }
  70.  
  71.  
  72.  
  73. /*****************************************************************************/
  74.  
  75.  
  76.  
  77. /* SoundInputAvaliable
  78. **
  79. ** Sound input is avaliable if there's a device registered…
  80. */
  81.  
  82. #pragma segment Main
  83. Boolean SoundInputAvaliable(void)
  84. {
  85.     Boolean        siPresent;
  86.     Handle        devIconHandle;
  87.     Str255        devName;
  88.     NumVersion    vers;
  89.     
  90.     siPresent = false;
  91.     
  92.     if (gSystemVersion >= 0x0700) {
  93.         vers = SndSoundManagerVersion();
  94.         if (vers.majorRev > 0) {
  95.             if (SPBGetIndexedDevice(1, devName, &devIconHandle) == noErr) {
  96.                 DisposHandle(devIconHandle);
  97.                 siPresent = true;
  98.             }
  99.         }
  100.     }
  101.  
  102.     return(siPresent);
  103. }
  104.  
  105.  
  106.  
  107.